home *** CD-ROM | disk | FTP | other *** search
- /* Programmer's guide to GEM - 1986 - p.158 -listing 3.2 - CJPurcell Dec'86 */
- /* CTRLRC.C - MAIN DRIVER for draw_rc() examples using Mark Williams C */
- /* to be tested in NDC and/or RC mode with or without GDOS for implications */
- #include <portab.h> /* MWC consistant ?? */
- #include <osbind.h> /* system constants */
- #include <gemdefs.h> /* GEM-definition */
- /* #include <obdefs.h> manually CJP / * object definition */
-
- WORD contrl[12], intin[128], ptsin[128], intout[128], ptsout[128];
-
- #define M_OFF 256
- #define RC_COORDS 2
- #define RIGHT_ALIGNED 2
- #define BOTTOM_ALIGNED 3
-
- VOID main() /* not GEMAIN as in ref. */
- {
- WORD handle, work_in[11], work_out[57], max_w, max_h;
- WORD ii;
-
- appl_init(); /* init AES for call */
- handle = graf_handle( &ii,&ii,&ii,&ii ); /* get screen handle */
- graf_mouse( M_OFF, NULL ); /* hide mouse */
- v_clrwk( handle ); /* clear workstation */
-
- for( ii=0; ii<11; ++ii ) work_in[ii]=1; /* init work_in array*/
- work_in[10] = RC_COORDS; /* using RC coordinates */
- v_opnvwk( work_in, &handle, work_out ); /* open the workstation */
-
- max_w = work_out[0]; max_h = work_out[1];
- draw_rc( handle,0,0,max_w,max_h ); /* do the examp.routine */
-
- vst_alignment( handle,RIGHT_ALIGNED,BOTTOM_ALIGNED,&ii,&ii );
- v_gtext( handle,max_w,max_h,"Press any Key to Continue" );
- evnt_keybd(); /* pause for viewing */
- v_clsvwk( handle ); /* close workstation */
- appl_exit(); /* tell AES finished */
- }
-
- /* ref.p.236/7-Listing 3.23 CPYTRAN2.C - Display 2 live bug images on screen */
- #define LEFT 0
- #define WHITE 0
- #define ADDR /*?*/ /* ? as in machine.h */
- #define MD_REPLACE 1 /* ? as in machine.h */
- #define BLACK 1
- #define ImageBytes 2 /* # bytes in raster */
- #define FIS_PATTERN 2
- #define MD_XOR 3
- #define TOP 5
- #define ImageRows 10 /* rows */
- #define ImageBitWidth 11 /* # significant bits*/
-
- WORD image1[10] = { 0x9200,0x4900,0x2480,0x3f80,0x7fd0,
- 0x7fd0,0x3f80,0x2480,0x4900,0x9200 };
- WORD image2[10] = { 0x2480,0x2480,0x2480,0x3f80,0x7fd0,
- 0x7fd0,0x3f80,0x2480,0x2480,0x2480 };
- WORD image3[10] = { 0x0920,0x1240,0x2480,0x3f80,0x7fd0,
- 0x7fd0,0x3f80,0x2480,0x1240,0x0920 };
-
- VOID draw_rc( handle, dx, dy, swidth, sheight )
- WORD handle, dx, dy, swidth, sheight;
- {
- FDB img_m[3], scr_m ;
- WORD ii, cur_x, cur_y, y_incr, pxy[8], colors[2];
-
- y_incr = sheight / 3;
- cur_y = dy + y_incr;
- vst_alignment( handle, LEFT, TOP, &ii, &ii );
- v_gtext( handle, dx + swidth/2, cur_y, "This line uses REPLACE MODE");
- v_gtext( handle, dx +swidth/2,cur_y+ y_incr,"This line uses XOR MODE");
-
- pxy[0] = dx + swidth / 20 ; /* display backdrop to crawl thru */
- pxy[1] = dy + sheight / 10 ;
- pxy[2] = dx + (swidth / 2) - ( swidth / 20 );
- pxy[3] = dy + sheight - (sheight / 10 );
-
- vsf_color ( handle, BLACK );
- vsf_interior( handle, FIS_PATTERN );
- vsf_style ( handle, 3 );
- v_rfbox ( handle, pxy);
- /* initialize all 3 FDB's */
- img_m[0].fd_addr = ADDR( image1 ) ;
- img_m[1].fd_addr = ADDR( image2 ) ;
- img_m[2].fd_addr = ADDR( image3 ) ;
- for( ii = 0 ; ii < 3 ; ++ii )
- {
- img_m[ii].fd_w = ImageBytes << 3 ;
- img_m[ii].fd_h = ImageRows ;
- img_m[ii].fd_wdwidth = ImageBytes >> 1 ;
- img_m[ii].fd_stand = 1 ;
- img_m[ii].fd_nplanes = 1 ;
- img_m[ii].fd_r1 = img_m[ii].fd_r2 = img_m[ii].fd_r3 = 0 ;
- vr_trnfm( handle, &img_m[ii], &img_m[ii] ) ; /* in place transform */
- }
- scr_m.fd_addr = 0L ; /* Screen FDB -> physical device */
- colors[0] = BLACK ; colors[1] = WHITE ; /* Black and White */
-
- pxy[0] = 0 ;
- pxy[1] = 0 ;
- pxy[2] = pxy[0] + ImageBitWidth -1 ;
- pxy[3] = pxy[1] + ImageRows - 1 ;
-
- for( cur_x = dx ; cur_x < (dx + swidth / 2) - ImageBitWidth ; ++cur_x )
- {
- pxy[4] = cur_x ;
- pxy[6] = pxy[4] + ImageBitWidth ;
- for ( ii = 0 ; ii < 3 ; ++ ii )
- {
- pxy[5] = cur_y + y_incr ;
- pxy[7] = pxy[5] + ImageRows ;
- vrt_cpyfm(handle,MD_XOR, pxy,&img_m[ii],&scr_m,colors);
- pxy[5] = cur_y ;
- pxy[7] = pxy[5] + ImageRows ;
- vrt_cpyfm(handle,MD_REPLACE,pxy,&img_m[ii],&scr_m,colors);
- pxy[5] = cur_y + y_incr ;
- pxy[7] = pxy[5] + ImageRows ;
- vrt_cpyfm(handle,MD_XOR, pxy,&img_m[ii],&scr_m,colors);
- }
- }
- /* display for one last time so as to leave an image on the screen */
- vrt_cpyfm( handle, MD_XOR, pxy, &img_m[2], &scr_m, colors ) ; /* BITBLT */
- } /*CJPurcell 08Dec'86*/
-